unit Parameter;

interface

uses
  Winapi.Windows, Winapi.Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses,
  uniGUIClasses, uniGUIForm, uniGUIBaseClasses, uniCheckBox, uniDBCheckBox, DB,
  uniPanel, uniPageControl, AppServer, DBClient, ClientRowSet;

type
  TFrmParameter = class(TUniForm)
    UniPageControl1: TUniPageControl;
    UniTabSheet1: TUniTabSheet;
    dsParam: TDataSource;
    ckRcvBillSMS: TUniCheckBox;
    ckArivAllSMS: TUniCheckBox;
    ckRcvPerson: TUniCheckBox;
    UniTabSheet2: TUniTabSheet;
    ckBlanceCOD: TUniCheckBox;
    procedure ckArivAllSMSClick(Sender: TObject);
    procedure ckRcvPersonClick(Sender: TObject);
    procedure ckRcvBillSMSClick(Sender: TObject);
    procedure UniFormShow(Sender: TObject);
    procedure ckBlanceFeeClick(Sender: TObject);
    procedure ckBlanceCODClick(Sender: TObject);
    procedure UniFormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure UpdateParameter(pmname:String;checked:boolean);
  public
    { Public declarations }
    procedure ShowParameter;
  end;

function FrmParameter: TFrmParameter;

implementation

{$R *.dfm}

uses
  MainModule, uniGUIApplication,expmodule, uCommFunction;

function FrmParameter: TFrmParameter;
begin
  Result := TFrmParameter(UniMainModule.GetFormInstance(TFrmParameter));
end;

{ TFrmParameter }

procedure TFrmParameter.ckArivAllSMSClick(Sender: TObject);
begin
  self.UpdateParameter('ARV_SMS_ALL',ckArivAllSMS.Checked);
end;

procedure TFrmParameter.ckRcvBillSMSClick(Sender: TObject);
begin
  self.UpdateParameter('RCV_SMS',ckRcvBillSMS.Checked);
end;

procedure TFrmParameter.ckRcvPersonClick(Sender: TObject);
begin
  self.UpdateParameter('INPUT_RCVPSRN',ckRcvPerson.Checked);
end;

procedure TFrmParameter.ShowParameter;
begin
  ckArivAllSMS.Checked := dsParam.DataSet.FieldByName('ARV_SMS_ALL').AsInteger = 1;
  ckRcvPerson.Checked  := dsParam.DataSet.FieldByName('INPUT_RCVPSRN').AsInteger = 1;
  ckRcvBillSMS.Checked := dsParam.DataSet.FieldByName('RCV_SMS').AsInteger = 1;
  ckBlanceCOD.Checked  := dsParam.DataSet.FieldByName('BLANCE_COD').AsInteger = 1;
end;

procedure TFrmParameter.ckBlanceCODClick(Sender: TObject);
begin
  self.UpdateParameter('BLANCE_COD',ckBlanceCOD.Checked);
end;

procedure TFrmParameter.ckBlanceFeeClick(Sender: TObject);
begin
//  self.UpdateParameter('BLANCE_FEE',ckBlanceFee.Checked);
end;

procedure TFrmParameter.UniFormCreate(Sender: TObject);
begin
  SetCompoentLanguage(Self);
end;

procedure TFrmParameter.UniFormShow(Sender: TObject);
begin
  ShowParameter;
end;

procedure TFrmParameter.UpdateParameter(pmname: String; checked: boolean);
begin
  dsParam.DataSet.Edit;
  if checked then
    dsParam.DataSet.FieldByName(pmname).AsInteger := 1
  else
    dsParam.DataSet.FieldByName(pmname).AsInteger := 0;
  TClientRowset(dsParam.DataSet).ApplyUpdates;
end;

end.
